#include <iostream>
#include <vector>
#include <queue>
#include "TOOL//tool.h"
using namespace std;

class Solution {
public:
    vector<int> maxSlidingWindow(vector<int>& nums, int k) {
        int n = nums.size();
        priority_queue<pair<int, int>> q;
        for (int i = 0; i < k; ++i) {
            //q.emplace(nums[i], i);
            q.push({nums[i], i});
        }
        vector<int> ans = {q.top().first};
        for (int i = k; i < n; ++i) {
            q.emplace(nums[i], i);
            int a=q.top().second;
            int b=i-k;
            while (q.top().second <= i - k) {
                q.pop();
            }
            ans.push_back(q.top().first);
        }
        return ans;
    }
};


void testS()
{
    vector<int>nums = {1,3,-1,-3,5,3,6,7};
    int k = 3;
    Solution ad;
    vector<int>ans=ad.maxSlidingWindow(nums,k);
    printV(ans);
}







